package javao.cn.modules.sys.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javao.cn.modules.sys.entity.SysAnnouncementsEntity;
import javao.cn.modules.sys.service.SysAnnouncementsService;
import javao.cn.common.utils.PageUtils;
import javao.cn.common.utils.R;



/**
 * 公告信息管理
 *
 * @author xx
 * @email xxx@qq.com
 * @date 2024-12-04 11:18:49
 */
@RestController
@RequestMapping("sys/sysannouncements")
public class SysAnnouncementsController {
    @Autowired
    private SysAnnouncementsService sysAnnouncementsService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("sys:sysannouncements:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = sysAnnouncementsService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("sys:sysannouncements:info")
    public R info(@PathVariable("id") Long id){
		SysAnnouncementsEntity sysAnnouncements = sysAnnouncementsService.getById(id);

        return R.ok().put("sysAnnouncements", sysAnnouncements);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("sys:sysannouncements:save")
    public R save(@RequestBody SysAnnouncementsEntity sysAnnouncements){
		sysAnnouncementsService.save(sysAnnouncements);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("sys:sysannouncements:update")
    public R update(@RequestBody SysAnnouncementsEntity sysAnnouncements){
		sysAnnouncementsService.updateById(sysAnnouncements);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("sys:sysannouncements:delete")
    public R delete(@RequestBody Long[] ids){
		sysAnnouncementsService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
